import csv
import numpy as np
import pandas as pd
from collections import Counter
from matplotlib import pyplot as plt

plt.style.use('fivethirtyeight')

language_counter = Counter()
# with open('data.csv') as f:
#     csv_reader = csv.DictReader(f, delimiter=',')#
#     for row in csv_reader:
#         language_counter.update(row['LanguagesWorkedWith'].split(';'))
data = pd.read_csv('bar_pie_data.csv')
for langs in data['LanguagesWorkedWith']:
    language_counter.update(langs.split(';'))

languages = []
popularities = []
for language, popularity in language_counter.most_common(20):
    languages.append(language)
    popularities.append(popularity)
languages.reverse()
popularities.reverse()

plt.barh(languages, popularities)
plt.title('Most Popular Languages')
plt.xlabel('Number of People Who Use')
# plt.ylabel('Programming Languages')

plt.tight_layout()
plt.show()
